package com.esiag.isidis.fi.pdsTeam.jms.consumer;

import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.ObjectMessage;

import com.esiag.isidis.fi.pdsTeam.jms.chooser.IActionChooser;

import com.esiag.isidis.fi.pdsTeam.jms.consumer.ActiveMQConsumer;
import com.esiag.isidis.fi.pdsTeam.receive.beans.Action;

public class Consumer extends ActiveMQConsumer{
	
	private IActionChooser mActionChooser;
	
	public Consumer(IActionChooser pActionChooser) {
		super(Action.class);
		mActionChooser = pActionChooser;
	}

	public void onMessage(Message pMessage) {
		
		ObjectMessage msg = (ObjectMessage) pMessage;
		try {
			Action action = (Action) msg.getObject();
			mActionChooser.chooseAction(action);
			
		} catch (JMSException e) {
			e.printStackTrace();
		}
		
	}

}
